import java.util.Arrays;
import java.util.Locale;

class Person{
    public String name;
    public int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Text2 {
    public static void main(String[] args) {
        //数值转变为字符串
        String str1=String.valueOf(1234);
        System.out.println(str1);
        //valueOf其他类型的转换
        String str2=String.valueOf(new Person("Zhangsan",18));
        System.out.println(str2);
        System.out.println("==================");
        //所有字符串的修改都不是在原来值的基础上的，通常都是有返回值，返回新的字符串
        String str3="hello";
        String ret=str3.toUpperCase();//小写转大写
        System.out.println(ret);
        String str4="HELLO";
        String ret2=str4.toLowerCase();
        System.out.println(ret2);
        System.out.println("=========");
        //将字符串转变为数组
        String str5="helloworld";
        char[] array=str5.toCharArray();
        System.out.println(Arrays.toString(array));
        System.out.println("=============");
        //字符替换
        String str6="abaffjkababuueee";
        String let=str6.replaceFirst("ab","000");
        System.out.println(let);
        System.out.println("--------------");
        String let2=str6.replaceAll("ab","000");
        System.out.println(let2);
        System.out.println("-------------");
        String let3=str6.replace("ab","000");
        System.out.println(let3);
        System.out.println("--------------");
        String let4=str6.replace("a","p");
        System.out.println(let4);

    }
}
